package org.darkforest.controller;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import org.darkforest.common.services.GoodsClassRedisService;
import org.darkforest.model.GoodsClass;
import org.darkforest.model.RestEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品分类 从redis获取
 * @auth bingo
 * @create 2017-10-10-16:44
 */
@RestController
@RequestMapping(value = "category")
@Api(value = "category", description = "商品分类",produces= MediaType.APPLICATION_JSON_VALUE)
public class CategoryController {
    @Autowired
    private GoodsClassRedisService goodsClassRedisService;
    /**
     * 获取一级分类
     * @return
     */
    @RequestMapping(value = "firstLevel",method = RequestMethod.GET)
    @ApiOperation(value = "获取一级分类", httpMethod = "GET",produces= MediaType.APPLICATION_JSON_VALUE)
    public RestEntity firstLevel(){
       List<GoodsClass> goodsClassList =  goodsClassRedisService.getGoodsClassList(null);
       return RestEntity.success(goodsClassList);
    }


}
